﻿(function(window){
var tabscommon = function(ptag,pcnt,num){
	var tags = ptag.getElementsByTagName('li'),
		cnts = pcnt.getElementsByTagName('div'),
		clsn = 'active',//
		numb = num,//
		i=0,
		tabCollection = [],
		currentab = 0,
		
	 	tabModule = function(tag, cnt, numb){
			this.tag = tag;
			this.content = cnt;
			this.number = numb;
		};
	
	for(;i<numb;i++){
		tabCollection.push(new tabModule(tags[i],cnts[i],i));
	}
	
	
	for(i=0;i<numb;i++){
		(function(){
			var tab = tabCollection[i];
			addEvent(tab.tag,'mouseover',function(){
				if(tab.tag.className != clsn){
					tab.id = 
					window.setTimeout(function(){
						tabCollection[currentab].tag.className = '';
						tabCollection[currentab].content.className = '';
						tab.tag.className = 'active';
						tab.content.className = 'on';
						currentab = tab.number;
					},300);
					
				}
			});
			
			
			addEvent(tab.tag,'mouseout',function(){
				if(tab.id != null){
					window.clearTimeout(tab.id);
					tab.id = null;
				}
			});
			
		})();
	}
	
	
}
window.tabscommon = tabscommon;
})(window);